package com.qdaily.ui.ui;

import android.os.Bundle;
import android.text.TextUtils;
import com.qdaily.ui.QDBaseActivity;
import com.qdaily.ui.R;
import com.qdaily.ui.net.QDEnum;
import com.qdaily.ui.ui.fragment.CategoryFragment;

/**
 * 侧边栏跳转，或者[这个设计了不起]
 * 分类文章列表。
 * Created with IntelliJ IDEA.
 * User: Felix
 * Date: 5/5/15
 * Time: 18:35
 * QQ:74104
 * Email:lovejiuwei@gmail.com
 */
public class CategoryActivity extends QDBaseActivity {
    public static final String KEY_CATEGORY_TYPE = "KEY_CATEGORY_TYPE";
    public static final String KEY_CATEGORY_ID = "KEY_CATEGORY_ID";
    public static final String KEY_CATEGORY_TITLE = "KEY_CATEGORY_TITLE";
    private int categoryId = 0;
    private String titleText = "";
    private QDEnum.CategoryFragmentEnum mCurCategoryType;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_frgment_container);

        categoryId = getIntent().getIntExtra(KEY_CATEGORY_ID, 0);
        titleText = getIntent().getStringExtra(KEY_CATEGORY_TITLE);
        if (TextUtils.isEmpty(titleText)) {
            titleText = "";
        }

        mCurCategoryType = (QDEnum.CategoryFragmentEnum) getIntent().getSerializableExtra(KEY_CATEGORY_TYPE);
        if (mCurCategoryType == null) {
            mCurCategoryType = QDEnum.CategoryFragmentEnum.CATEGORY;
        }

        pushFragmentToBackStack(CategoryFragment.class, new CategoryFragment.CategoryDataObj().
                setCategoryFragmetType(mCurCategoryType)
                .setIsTitlebarLeftBtnVisiable(true)
                .setTitleText(titleText)
                .setCategoryId(categoryId));
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.content_frame;
    }
}
